package com.it2297.model;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.it2297.main.App;

public class FamilyDetails {
	
	private String Name;
	private String Relationship;
	private String Occupation;
	private String NRIC;
	private double AnnualIncome;
	private String NeedyNRIC;
	
	
	public String getNeedyNRIC() {
		return NeedyNRIC;
	}

	public void setNeedyNRIC(String needyNRIC) {
		NeedyNRIC = needyNRIC;
	}

	public String getName() {
		return Name;
	}
	
	public void setName(String name) {
		Name = name;
	}
	
	public String getRelationship() {
		return Relationship;
	}
	
	public void setRelationship(String relationship) {
		Relationship = relationship;
	}
	
	public String getOccupation() {
		return Occupation;
	}
	
	public void setOccupation(String occupation) {
		Occupation = occupation;
	}
	
	public String getNRIC() {
		return NRIC;
	}
	
	public void setNRIC(String nRIC) {
		NRIC = nRIC;
	}
	
	public double getAnnualIncome() {
		return AnnualIncome;
	}
	////
	public void setAnnualIncome(double annualIncome) {
		AnnualIncome = annualIncome;
	}
	
	public static FamilyDetails getFamilyDetails() {

		 FamilyDetails family = new FamilyDetails();
//
		try {
			App.mySqlConnection.open();

			ResultSet resultSet = App.mySqlConnection.executeQuery("SELECT * FROM americano.family WHERE nric = 'S9999999T'");

				while (resultSet.next()) {
				
			    family.setName(resultSet.getString("name"));
			    family.setRelationship(resultSet.getString("relationship"));
			    family.setOccupation(resultSet.getString("occupation"));
			    family.setNRIC(resultSet.getString("nric"));
			    family.setAnnualIncome(resultSet.getDouble("annual_income"));
			    family.setNeedyNRIC(resultSet.getString("fk_nric"));
			    
			}

		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			App.mySqlConnection.close();
		}

		return family;
	}
	
	
	
	
	
	
	
	
	

}